home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk28 / getfil / testing.c < prev   
C/C++ Source or Header  |  1995-03-18  |  3KB  |  119 lines

  1. /* testing.c */
  2. /* comes with PowerWindows 2.0 */
  3.  
  4.  
  5. #include <exec/types.h>
  6. #include <intuition/intuition.h>
  7. #include <libraries/dosextens.h>
  8. #include <functions.h>
  9.  
  10. #define I_REV   31
  11. #define G_REV   31
  12. #define    EWDTH    640
  13. #define    EHGHT    198
  14. #define    NL    NULL
  15.  
  16. struct IntuitionBase *IntuitionBase;
  17. struct GfxBase
  18. {
  19.     int b;
  20. } *GfxBase;
  21.  
  22. struct NewScreen TS =
  23. {
  24.     0,0,640,200,2,
  25.     1,2,
  26.     HIRES,    WBENCHSCREEN,
  27.     0L, 0L, 0L
  28. };
  29.  
  30. /* Used to open a Window   */
  31. struct NewWindow EdWindow =
  32. {
  33.     0,2,EWDTH,EHGHT-2,        /* LeftEdge,TopEdge,Width,Height */
  34.     1,2,            /* DetailPen,BlockPen    */
  35.     MENUPICK | NEWSIZE | REFRESHWINDOW | ACTIVEWINDOW |
  36.     MOUSEBUTTONS | RAWKEY | MOUSEMOVE,
  37.     WINDOWDRAG | WINDOWSIZING | SIMPLE_REFRESH | ACTIVATE | WINDOWDEPTH,
  38.     NL,NL,"Window",        /* FirstGadget, CheckMark, Title  */
  39.     NL,                /* Screen ( Null)    */
  40.     NL,                /* BitMap        */
  41.     150,45,32767,32767,        /* MinW, MinH, MaxW, MaxH */
  42.     CUSTOMSCREEN        /* Type            */
  43. };
  44.  
  45. main()
  46. {
  47.     struct Window    *eW;
  48.     struct Screen    *eS;
  49.  
  50.     struct Process    *OurTask;
  51.     struct Window    *old_pr_WindowPtr;
  52.  
  53.     static char    default_name[50] = "";
  54.     static char    default_path[50] = "df0:";
  55.  
  56.     if (!(IntuitionBase = (struct IntuitionBase *)
  57.         OpenLibrary("intuition.library",(long)I_REV)) ||
  58.         !(GfxBase =(struct GfxBase *)OpenLibrary("graphics.library",
  59.         (long)G_REV)) )
  60.     {
  61.         printf("Can't open libraries\n");
  62.         exit(20);
  63.     }
  64.  
  65.     if (!(eS = (struct Screen *)OpenScreen(&TS)) )
  66.     {
  67.         printf("Can't Open Screen!!!!!\n");
  68.         exit(22);
  69.     }
  70.  
  71.     EdWindow.Screen = eS;
  72.  
  73.     if (!(eW =(struct Window *)OpenWindow(&EdWindow)) )
  74.     {
  75.         CloseScreen(eS);
  76.         printf("Can't open window...\n");
  77.         exit(21);
  78.     }
  79.  
  80.     /* CAUTION!!! KNOW ABOUT pr_WindowPtr before you use it!!! */
  81.  
  82.     OurTask = (struct Process *)FindTask(0L);
  83.     old_pr_WindowPtr = OurTask->pr_WindowPtr;
  84.     OurTask->pr_WindowPtr = eW;
  85.  
  86.     /* Here comes the test... */
  87.  
  88.     /* try something unlikely */
  89.     strcpy (default_path, "df5:");
  90.  
  91.     printf ("First try:\n");
  92.     if (!get_fname(eW,eS,"Load File",default_name,default_path," Load"))
  93.         printf ("Could not open requester\n");
  94.     else
  95.     {
  96.         printf ("File name is: \'%s\'\n",default_name);
  97.         printf ("Directory is: \'%s\'\n",default_path);
  98.     }
  99.  
  100.     /* use same file and path as last time */
  101.     printf ("Second try:\n");
  102.     if (!get_fname(eW,eS,"Select File",default_name,default_path, 0))
  103.         printf ("Could not open requester\n");
  104.     else
  105.     {
  106.         printf ("File name is: \'%s\'\n",default_name);
  107.         printf ("Directory is: \'%s\'\n",default_path);
  108.     }
  109.  
  110.     /* ALWAYS RESTORE pr_WindowPtr BEFORE CLOSING THE WINDOW!!! */
  111.     OurTask->pr_WindowPtr = old_pr_WindowPtr;
  112.  
  113.     CloseWindow(eW);
  114.     CloseScreen(eS);
  115.     CloseLibrary(GfxBase);
  116.     CloseLibrary(IntuitionBase);
  117. }
  118.  
  119.